package com.fw4j.jdbc.factory;

import java.sql.SQLException;

import com.fw4j.jdbc.engine.TransactionCallback2;
import com.fw4j.jdbc.entity.ClassInfo;
import com.fw4j.jdbc.exception.InstanceException;




public class DaoFactory2 {
	private static ClassInfo classInfo = null;
	
	public static synchronized void transaction(TransactionCallback2 callback){
		DaoInstance d = new DaoInstance();
		try {
			d.conn.setAutoCommit(false);
			callback.invoke(d);
			d.conn.commit();
		} catch (SQLException e) {
			try {
				d.conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}
		try {
			d.conn.close();
			d.conn = null;
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	public static <T> T getInstance(Class<T> cl) throws InstanceException{
		return new DaoInstance().getInstance(cl);
	}
}
